#include "video_stitching.h"
#include "ui_video_stitching.h"
#include<qfiledialog.h>
#include<addyiping.h>

video_stitching::video_stitching(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::video_stitching)
{
    ui->setupUi(this);

    connect(&video_stitch,&addyiping::signal_outtext,[=](QString str)
    {
        ui->plainTextEdit->appendPlainText(str);
    }
            );

    connect(&video_stitch,&addyiping::signal_addyinping_over,[=](){ui->plainTextEdit->appendPlainText("拼接视频完成!!!");});
}

video_stitching::~video_stitching()
{
    delete ui;
}

void video_stitching::on_Button_sp1_clicked()
{
    sp1=QFileDialog::getOpenFileName(this,"选择视频1","","视频 (*.mp4 *.wmv *.mpeg)");
    ui->plainTextEdit->appendPlainText(sp1);
}

void video_stitching::on_Button_sp2_clicked()
{
    sp2=QFileDialog::getOpenFileName(this,"选择视频2","","视频 (*.mp4 *.wmv *.mpeg)");
    ui->plainTextEdit->appendPlainText(sp2);
}

void video_stitching::on_Button_start_clicked()
{
    if(sp1.isEmpty()==true||sp2.isEmpty()==true)
    {
        ui->plainTextEdit->appendPlainText("未选择视频文件!!!");
        return;
    }

    //addyiping* video_stitch=new addyiping(NULL);

//    connect(&video_stitch,&addyiping::signal_outtext,[=](QString str)
//    {
//        ui->plainTextEdit->appendPlainText(str);
//    }
//            );

//    connect(&video_stitch,&addyiping::signal_addyinping_over,[=](){ui->plainTextEdit->appendPlainText("拼接视频完成!!!");});
    //connect(video_stitch,&addyiping::signal_addyinping_over,video_stitch,&QObject::deleteLater);


    QString outfile=sp2;
    outfile.insert(outfile.length()-4,"拼接");
    video_stitch.video_stitch(sp1,sp2,outfile);

    return;
}
